import Rect from "./Rect";
import Circle from "./Circle";

import withDragEvent from "../hoc/withDragEvent";

const itemTypes = {
  rect: Rect,
  circle: Circle,
};

export default function Item(props: ItemProp) {
  const { itemType, x, y, index } = props;
  const TargetItem = withDragEvent(itemTypes[itemType], {
    x: x,
    y: y,
    index: index,
  });
  return <TargetItem />;
}

export interface ItemProp {
  itemType: "rect" | "circle";
  x: string;
  y: string;
  index: number;
}
